<template>
	<view class="freeFloating" v-if="props.freeCode">
		<view class="listItem" v-for="(item,index) in [data.freeInfo]" :key="index">
			<view class="top">
				<view class="left">
					<image :src="data.httpUrl+'/app/file/viewFile?fileId='+item.publishUserAvatarId" mode="aspectFill">
					</image>
					<text class="ellipsis_1">{{item.publishUserName}}</text>
				</view>
				<view class="right">
					<view class="ellipsis_2">
						发起了一笔
						<text>{{item.freeAmount}}</text>
						元免单互动
					</view>
				</view>
			</view>
			<view class="top_1">
				<view class="left">
					<!-- 立即分享 -->
				</view>
				<view class="right">
					<view class="item" v-for="(item1,index1) in item.inviteUsers.slice(0,2)" :key="index1">
						<image v-if="item1.userAvatarId"
							:src="data.httpUrl+'/app/file/viewFile?fileId='+item1.userAvatarId" mode="aspectFill">
						</image>
						{{!item1.userAvatarId?'?':''}}
						<text :class="item1.userAvatarId?'active':''">{{item1.percent}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { queryJoinDetailByFreeCode } from '@/utils/api/goods'
	import { reactive } from 'vue';
	const props = defineProps(['freeCode'])
	const data = reactive<any>({
		freeInfo: {},
		httpUrl: getApp().globalData.baseUrl,
	})
	if (props.freeCode) {
		queryJoinDetailByFreeCode({ data: { freeCode: props.freeCode } }).then((res) => {
			data.freeInfo = res.data;
		})
	}
</script>

<style lang="scss">
	.freeFloating {
		width: 357rpx;
		position: absolute;
		right: 24rpx;
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
		bottom: 250rpx;
		z-index: 11;

		.listItem {
			margin-top: 20rpx;
			padding: 20rpx 20rpx 0 20rpx;
			border-radius: 24rpx;
			background: #fff;

			>.top {
				display: flex;
				align-items: flex-start;

				.left {
					position: relative;
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
					border: 2rpx solid #FF263F;
					margin-right: 32rpx;

					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}

					text {
						width: 102rpx;
						line-height: 44rpx;
						text-align: center;
						background: #FF263F;
						border-radius: 8rpx;
						font-size: 24rpx;
						color: #fff;
						position: absolute;
						left: 50%;
						bottom: -8rpx;
						margin-left: -51rpx;
					}
				}

				.right {
					flex: 1;

					view {
						font-size: 32rpx;

						text {
							font-size: 32rpx;
							color: #FF263F;
						}
					}

					>text {
						color: #8C8C8C;
					}
				}
			}

			>.top_1 {
				display: flex;
				align-items: flex-end;
				position: relative;
				top: -20rpx;

				.left {
					width: 125rpx;
					line-height: 44rpx;
					text-align: center;
					border-radius: 22rpx;
					background: linear-gradient(233deg, #FFA34B 0%, #FF8E6F 100%);
					color: #fff;
					font-size: 24rpx;
					margin-right: 27rpx;
				}

				.right {
					height: 96rpx;
					display: flex;
					flex: 1;
					flex-wrap: wrap;
					position: relative;

					view {
						width: 96rpx;
						height: 96rpx;
						border-radius: 50%;
						border: 2rpx dashed #F0F0F0;
						display: flex;
						align-items: center;
						margin-right: 3rpx;
						justify-content: center;
						color: #8C8C8C;
						font-size: 29rpx;
						font-weight: bold;
						position: absolute;
						top: 0;
						left: 0;

						image {
							width: 100%;
							height: 100%;
							border-radius: 50%;
						}

						text {
							position: absolute;
							right: 0;
							bottom: 0;
							width: 63rpx;
							line-height: 44rpx;
							text-align: center;
							display: inline-block;
							border-radius: 8rpx;
							background: #F4F6FA;
							color: #BFBFBF;

							font-size: 24rpx;
							font-weight: bold;
						}

						.active {
							background: #EDFCD2;
							color: #6AC922;
						}
					}

					>view:nth-of-type(1) {
						left: 80rpx;
					}

					>view:last-child {
						margin-right: 0;
					}
				}
			}

		}
	}
</style>